home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
PET
/
S-Super PET
/
(s)tk.d64
/
trs80pUTcHAR.ASM
< prev
next >
Wrap
Assembly Source File
|
2009-01-18
|
4KB
|
151 lines
;TRS80 - DMP 105 printer driver written by Avygdor Moise.
; This program will enable all SuperPET programs to use TRS 80
; printer via the RS-232C interface using the 'Put serial'
; command (from editors, languages and PetCom's List mode) .
opt nolist
xref TBreak_ ,ACIAstatus, ACIAdata
xref STREq_
SysOpen_hook equ 14
SysOpen_offset equ 2*(SysOpen_hook+1)
SysWrite_hook equ 3
SysWrite_offset equ 2*(SysWrite_hook+1)
SysNL_hook equ 8
SysNL_offset equ 2*(SysNL_hook+1)
service_ equ $32
memtop_ equ $22
ldb #SysOpen_offset
stb $0580+SysOpen_hook ;connect to SysOpen
ldd #SysOpen
std $05c0+SysOpen_offset ;address of replacement to Sys$Open
ldb #SysWrite_offset
stb $0580+SysWrite_hook ;connect to SysWrite
ldd #SysWrite
std $05c0+SysWrite_offset ;address of replacement to Sys$write
ldb #SysNL_offset ;connect to SysNL
stb $0580+SysNL_hook
ldd #SysNL
std $05c0+SysNL_offset
ldd #start-1
std memtop_
clr service_
rts
start equ *
line_count fcb 0 ;number of lines to end of page
lines_per_page equ 66
serial equ $06 ;hook identification number for device
DSR_DCD_TDE_mask equ %01110000
ready equ %00010000
SysWrite equ *
ldx 5,s ;fcb
ldx 4,x ;point to file info
ldb 2,x ;get device type
cmpb #serial
if eq
pshs y
ldx 11,s ;buffer address
ldy 13,s ;buffer length
if ne
loop ;output the buffer
ldb ,x+
bsr SPutChar
leay -1,y ;decrement count
until eq
endif
puls y
leas 7,s ;drop SysWrite_
endif
rts
SysNL equ *
ldx 6,s
ldx 4,x
ldb 2,x
cmpb #serial
if eq
ldb #$0d
bsr SPutChar
leas 8,s
endif
rts
SPutChar equ *
pshs d,cc
guess
cmpb #$0a ;line feed ?
quif eq
cmpb #$0d ;let the printer empty its buffer
quif eq
cmpb #$0c
if eq
ldb #$0a ;linefeed
loop
bsr SPutChar
lda #lines_per_page
suba line_count
until eq
else
bsr SPutChar_
endif
admit
dec line_count
if eq
lda #lines_per_page
sta line_count
endif
bsr SPutChar_
endguess
puls cc,d,pc
SPutChar_ equ *
pshs a,cc
loop
lda #DSR_DCD_TDE_mask ;mask all but DSR,DCD,TDE
anda ACIAstatus
eora #ready ;is printer ready ?
quif eq
cwai #$ff ;wait for a transition
endloop
stb ACIAdata
cwai #$ff ;wait for acknnowledge
puls cc,a,pc
SysOpen equ *
ldd $3E,s ;get name string address
pshs d
ldd #interface
jsr streq_
leas 2,s
if ne
lda #66
sta line_count
endif
rts
interface fcc "serial"
fcb 0
end